package com.example.memolaga.accounts;

import android.os.Bundle;
import android.app.Activity;
import android.util.Log;
import android.view.Menu;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;

import com.example.memolaga.Constants;
import com.example.memolaga.Functions;
import com.example.memolaga.R;

public class AccAdd extends Activity {

    private String sKey;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        Bundle bundle = this.getIntent().getExtras();
        if (bundle!=null)
            this.sKey = bundle.getString(Constants.getKeyString());
        else
            Log.i("CredAdd", "sKey null");
        setContentView(R.layout.acc_add);
        ((Button) findViewById(R.id.btnAccSave)).setOnClickListener(btnSaveAcc);
    }

    private View.OnClickListener btnSaveAcc = new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            String name = ((EditText) findViewById(R.id.editAccNameAdd)).getText().toString();
            String server = ((EditText) findViewById(R.id.editAccServerAdd)).getText().toString();
            String path = ((EditText) findViewById(R.id.editAccPathAdd)).getText().toString();
            String userName = ((EditText) findViewById(R.id.editAccUsernameAdd)).getText().toString();
            String pass = ((EditText) findViewById(R.id.editAccPassAdd)).getText().toString();
            String provider = ((EditText) findViewById(R.id.editAccProviderAdd)).getText().toString();
            String provWebSite = ((EditText) findViewById(R.id.editAccProvWerAdd)).getText().toString();
            String provPhone = ((EditText) findViewById(R.id.editAccProvPhoneAdd)).getText().toString();
            String note = ((EditText) findViewById(R.id.editAccNoteAdd)).getText().toString();
            AccountsManager.getInstance().accAdd(name, server, path,userName, pass, provider, provWebSite, provPhone, note, sKey);
            Functions.showLongToast(getBaseContext(), getString(R.string.strOKCreateFile));
            setResult(Constants.getResultEdit());
            finish();
        }
    };
/*
    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        // Inflate the menu; this adds items to the action bar if it is present.
        getMenuInflater().inflate(R.menu.acc_add, menu);
        return true;
    }
    */
}
